<% line_item = inventory_unit.line_item %>

<div class="flex flex-col gap-4">
  <div class="flex gap-4">
    <div class="shrink-0">
      <% image = line_item.variant.default_image %>
      <% if image.present? && image.attached? && image.variable? %>
        <%= link_to spree_storefront_resource_url(line_item.product, relative: true) do %>
          <%= spree_image_tag(image, width: 128, height: 128, variant: :small, loading: :lazy) %>
        <% end %>
      <% else %>
        <div class="w-32 h-32 bg-accent"></div>
      <% end %>
    </div>
    <div class="flex flex-col gap-2">
      <div class="font-medium uppercase">
        <%= link_to line_item.name,
        spree_storefront_resource_url(line_item.product, relative: true) %>
      </div>
      <div class="font-medium">
        <%= line_item.display_price %>
      </div>
      <div class="flex flex-wrap gap-2">
        <%= render "spree/shared/line_item_options", line_item: line_item %>
        <div
          class="
            h-[30px] border border-default px-2 inline-flex items-center hover:border-dashed
            hover:border-primary text-sm
          "
        >
          <%= Spree.t(:quantity) %>:
          <%= inventory_unit.quantity %>
        </div>
      </div>
    </div>
  </div>
  <% if line_item.digital_links.any? %>
    <div class="flex flex-col gap-2">
      <span class="font-medium"><%= Spree.t(:attachments) %></span>
      <ul class="flex flex-col gap-1">
        <% line_item.digital_links.each do |digital_link| %>
          <li>
            <% if digital_link.authorizable? %>
              <%= link_to "#{Spree.t(:download)} #{digital_link.filename}",
              spree.digital_link_path(digital_link.token) %>
            <% else %>
              <span class="text-neutral cursor-not-allowed">
                <%= Spree.t(:download) %>
                <%= digital_link.filename %>
                (<%= Spree.t(:expired) %>)
              </span>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>
  <% end %>
  <div>
    <%= link_to Spree.t(:order_again),
    spree_storefront_resource_url(line_item.product, relative: true),
    class: "link" %>
  </div>
</div>
